home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / amos / AMOSP61Ext.lha / source / 610.2_devpac3.asm next >
Encoding:
Assembly Source File  |  1997-08-27  |  38.4 KB  |  2,484 lines

  1. * The Player 6.1A for Devpac 3 (and later ;) *
  2. * NEEDS:
  3. *        Default sizes must be words (ASM-One default...)
  4. *        Preferably no optimizations on (the jump table must be word jumps)
  5. * Tested with Devpac 3.04
  6.         
  7. ;start = 6    ;Starting position
  8.  
  9.  
  10. ;    incdir    include:
  11. ;    include Player61.i
  12.  
  13.  
  14. ;    section    Player6.1A,code
  15.  
  16. *********************************
  17. *        Player 6.1A ®        *
  18. *      All in one-version    *
  19. *        Version 610.2        *
  20. *   © 1992-95 Jarno Paananen    *
  21. *     All rights reserved    *
  22. *********************************
  23.  
  24.  
  25. ******** START OF BINARY FILE **************
  26.  
  27. P61_motuuli
  28. ;    bra.w    P61_Init
  29. ;    ifeq    CIA
  30. ;    bra.w    P61_Music
  31. ;    else
  32. ;    rts
  33. ;    rts
  34. ;    endc
  35. ;    bra.w    P61_End
  36. ;    rts                ;no P61_SetRepeat
  37. ;    rts
  38. ;    bra.w    P61_SetPosition
  39.  
  40. P61_Master    dc    64        ;Master volume (0-64)
  41. P61_FadeTo    dc    64        ;Target volume (0-64)
  42. P61_FadeSpeed    dc    1        ;Speed for fading
  43. P61_FadeCount    dc    0        ;Count for fading
  44. P61_Tempo    dc    1        ;Use tempo? 0=no,non-zero=yes
  45. P61_Play    dc    1        ;Stop flag (0=stop)
  46. P61_E8        dc    0        ;Info nybble after command E8
  47. P61_VBR        dc.l    0        ;If you're using non-valid execbase
  48.                     ;put VBR here! (Otherwise 0 assumed)
  49.                     ;You can also get VBR from here, if
  50.                     ;using exec-valid version
  51.  
  52. P61_Pos        dc    0        ;Current song position
  53. P61_Patt    dc    0        ;Current pattern
  54. P61_CRow    dc    0        ;Current pattern row
  55.  
  56. P61_Temp0Offset
  57.     dc.l    P61_temp0-P61_motuuli
  58. P61_Temp1Offset
  59.     dc.l    P61_temp1-P61_motuuli
  60. P61_Temp2Offset
  61.     dc.l    P61_temp2-P61_motuuli
  62. P61_Temp3Offset
  63.     dc.l    P61_temp3-P61_motuuli
  64.  
  65. P61_getnote    macro
  66.     moveq    #$7e,d0
  67.     and.b    (a5),d0
  68.     beq.b    .nonote
  69.     ifne    P61_vib
  70.     clr.b    P61_VibPos(a5)
  71.     endc
  72.     ifne    P61_tre
  73.     clr.b    P61_TrePos(a5)
  74.     endc
  75.  
  76.     ifne    P61_ft
  77.     add    P61_Fine(a5),d0
  78.     endc
  79.     move    d0,P61_Note(a5)
  80.     move    (a2,d0),P61_Period(a5)
  81.  
  82. .nonote
  83.     endm
  84.  
  85.     ifeq    system
  86.     ifne    CIA
  87. P61_intti
  88.     movem.l    d0-a6,-(sp)
  89.     tst.b    $bfdd00
  90.     lea    $dff000,a6
  91.     move    #$2000,$9c(a6)
  92. ;    move    #$fff,$180(a6)
  93.     bsr    P61_Music
  94. ;    move    #0,$180(a6)
  95.     movem.l    (sp)+,d0-a6
  96.     nop
  97.     rte
  98.     endc
  99.     endc
  100.  
  101.     ifne    system
  102. P61_lev6server
  103.     movem.l    d2-d7/a2-a6,-(sp)
  104.     lea    P61_timeron(pc),a0
  105.     tst    (a0)
  106.     beq.b    P61_ohi
  107.  
  108.     lea    $dff000,a6
  109.     move    P61_server(pc),d0
  110.     beq.b    P61_musica
  111.     subq    #1,d0
  112.     beq    P61_dmason
  113.     bra    P61_setrepeat
  114.  
  115. P61_musica
  116.     bsr    P61_Music
  117.  
  118. P61_ohi    movem.l    (sp)+,d2-d7/a2-a6
  119.     moveq    #1,d0
  120.     rts
  121.     endc
  122.  
  123. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  124. ;­ Call P61_Init to initialize the playroutine    ­
  125. ;­ D0 --> Timer detection (for CIA-version)    ­
  126. ;­ A0 --> Address to the module            ­
  127. ;­ A1 --> Address to samples/0 if in the module    ­
  128. ;­ A2 --> Address to sample buffer        ­
  129. ;­ D0 <-- 0 if succeeded            ­
  130. ;­ A6 <-- $DFF000                ­
  131. ;­         Uses D0-A6            ­
  132. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  133.  
  134. P61_Init
  135.     cmp.l    #"P61A",(a0)+
  136.     beq.b    .modok
  137.     subq.l    #4,a0
  138.  
  139. .modok
  140.     ifne    CIA
  141.     move    d0,-(sp)
  142.     endc
  143.  
  144.     moveq    #0,d0
  145.     cmp.l    d0,a1
  146.     bne.b    .redirect
  147.  
  148.     move    (a0),d0
  149.     lea    (a0,d0.l),a1
  150. .redirect
  151.     move.l    a2,a6
  152.     lea    8(a0),a2
  153.     moveq    #$40,d0
  154.     and.b    3(a0),d0
  155.     bne.b    .buffer
  156.     move.l    a1,a6
  157.     subq.l    #4,a2
  158. .buffer
  159.  
  160.     lea    P61_cn(pc),a3
  161.     moveq    #$1f,d1
  162.     and.b    3(a0),d1
  163.     move.l    a0,-(sp)
  164.     lea    P61_samples(pc),a4
  165.     subq    #1,d1
  166.     moveq    #0,d4
  167. P61_lopos
  168.     move.l    a6,(a4)+
  169.     move    (a2)+,d4
  170.     bpl.b    P61_kook
  171.     neg    d4
  172.     lea    P61_samples-16(pc),a5
  173.     ifeq    opt020
  174.     asl    #4,d4
  175.     move.l    (a5,d4),d6
  176.     else
  177.     add    d4,d4
  178.     move.l    (a5,d4*8),d6
  179.     endc
  180.     move.l    d6,-4(a4)
  181.     move    4(a5,d4),d4
  182.     sub.l    d4,a6
  183.     sub.l    d4,a6
  184.     bra.b    P61_jatk
  185.  
  186. P61_kook
  187.     move.l    a6,d6
  188.     tst.b    3(a0)
  189.     bpl.b    P61_jatk
  190.  
  191.     tst.b    (a2)
  192.     bmi.b    P61_jatk
  193.  
  194.     move    d4,d0
  195.     subq    #2,d0
  196.     bmi.b    P61_jatk
  197.  
  198.     move.l    a1,a5
  199.     move.b    (a5)+,d2
  200.     sub.b    (a5),d2
  201.     move.b    d2,(a5)+
  202. .loop    sub.b    (a5),d2
  203.     move.b    d2,(a5)+
  204.     sub.b    (a5),d2
  205.     move.b    d2,(a5)+
  206.     dbf    d0,.loop
  207.  
  208. P61_jatk
  209.     move    d4,(a4)+
  210.     moveq    #0,d2
  211.     move.b    (a2)+,d2
  212.     moveq    #0,d3
  213.     move.b    (a2)+,d3
  214.  
  215.     moveq    #0,d0
  216.     move    (a2)+,d0
  217.     bmi.b    .norepeat
  218.  
  219.     move    d4,d5
  220.     sub    d0,d5
  221.     move.l    d6,a5
  222.  
  223.     add.l    d0,a5
  224.     add.l    d0,a5
  225.  
  226.     move.l    a5,(a4)+
  227.     move    d5,(a4)+
  228.     bra.b    P61_gene
  229. .norepeat
  230.     move.l    d6,(a4)+
  231.     move    #1,(a4)+
  232. P61_gene
  233.     move    d3,(a4)+
  234.     moveq    #$f,d0
  235.     and    d2,d0
  236.     mulu    #74,d0
  237.     move    d0,(a4)+
  238.  
  239.     tst    -6(a2)
  240.     bmi.b    .nobuffer
  241.  
  242.     moveq    #$40,d0
  243.     and.b    3(a0),d0
  244.     beq.b    .nobuffer
  245.  
  246.     move    d4,d7
  247.     tst.b    d2
  248.     bpl.b    .copy
  249.  
  250.     subq    #1,d7
  251.     moveq    #0,d5
  252.     moveq    #0,d4
  253. .lo    move.b    (a1)+,d4
  254.     moveq    #$f,d3
  255.     and    d4,d3
  256.     lsr    #4,d4
  257.  
  258.     sub.b    .table(pc,d4),d5
  259.     move.b    d5,(a6)+
  260.     sub.b    .table(pc,d3),d5
  261.     move.b    d5,(a6)+
  262.     dbf    d7,.lo
  263.     bra.b    .kop
  264.  
  265. .copy    add    d7,d7
  266.     subq    #1,d7
  267. .cob    move.b    (a1)+,(a6)+
  268.     dbf    d7,.cob
  269.     bra.b    .kop
  270.  
  271. .table dc.b    0,1,2,4,8,16,32,64,128,-64,-32,-16,-8,-4,-2,-1
  272.  
  273. .nobuffer
  274.     move.l    d4,d6
  275.     add.l    d6,d6
  276.     add.l    d6,a6
  277.     add.l    d6,a1
  278. .kop    dbf    d1,P61_lopos
  279.  
  280.     move.l    (sp)+,a0
  281.     and.b    #$7f,3(a0)
  282.  
  283.     move.l    a2,-(sp)
  284.  
  285.     lea    P61_temp0(pc),a1
  286.     lea    P61_temp1(pc),a2
  287.     lea    P61_temp2(pc),a4
  288.     lea    P61_temp3(pc),a5
  289.     moveq    #Channel_Block_SIZE/2-2,d0
  290.  
  291.     moveq    #0,d1
  292. .cl    move    d1,(a1)+
  293.     move    d1,(a2)+
  294.     move    d1,(a4)+
  295.     move    d1,(a5)+
  296.     dbf    d0,.cl
  297.  
  298.     lea    P61_temp0-P61_cn(a3),a1
  299.     lea    P61_emptysample-P61_cn(a3),a2
  300.     moveq    #channels-1,d0
  301. .loo    move.l    a2,P61_Sample(a1)
  302.     lea    Channel_Block_SIZE(a1),a1
  303. ;    move.l    a2,P61_Sample(a2)
  304.     dbf    d0,.loo
  305.  
  306.     move.l    (sp)+,a2
  307.     move.l    a2,P61_positionbase-P61_cn(a3)
  308.  
  309.     moveq    #$7f,d1
  310.     and.b    2(a0),d1
  311.  
  312.     ifeq    opt020
  313.     lsl    #3,d1
  314.     lea    (a2,d1.l),a4
  315.     else
  316.     lea    (a2,d1.l*8),a4
  317.     endc
  318.     move.l    a4,P61_possibase-P61_cn(a3)
  319.  
  320.     move.l    a4,a1
  321.     moveq    #-1,d0
  322. .search    cmp.b    (a1)+,d0
  323.     bne.b    .search
  324.     move.l    a1,P61_patternbase-P61_cn(a3)    
  325.     move.l    a1,d0
  326.     sub.l    a4,d0
  327.     move    d0,P61_slen-P61_cn(a3)
  328.  
  329. ;    ifd    start
  330. ;    lea    start(a4),a4
  331. ;    endc
  332.  
  333.     moveq    #0,d0
  334.     move.b    (a4)+,d0
  335.     move.l    a4,P61_spos-P61_cn(a3)
  336.     lsl    #3,d0
  337.     add.l    d0,a2
  338.  
  339.     move.l    a1,a4
  340.     moveq    #0,d0    
  341.     move    (a2)+,d0
  342.     lea    (a4,d0.l),a1
  343.     move.l    a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  344.     move    (a2)+,d0
  345.     lea    (a4,d0.l),a1
  346.     move.l    a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  347.     move    (a2)+,d0
  348.     lea    (a4,d0.l),a1
  349.     move.l    a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  350.     move    (a2)+,d0
  351.     lea    (a4,d0.l),a1
  352.     move.l    a1,P61_ChaPos+P61_temp3-P61_cn(a3)
  353.  
  354.     lea    P61_setrepeat(pc),a0
  355.     move.l    a0,P61_intaddr-P61_cn(a3)
  356.  
  357.     move    #63,P61_rowpos-P61_cn(a3)
  358.     move    #6,P61_speed-P61_cn(a3)
  359.     move    #5,P61_speed2-P61_cn(a3)
  360.     clr    P61_speedis1-P61_cn(a3)
  361.  
  362.     ifne    P61_pl
  363.     clr.l    P61_plcount-P61_cn(a3)
  364.     endc
  365.  
  366.     ifne    P61_pde
  367.     clr    P61_pdelay-P61_cn(a3)
  368.     clr    P61_pdflag-P61_cn(a3)
  369.     endc
  370.     clr    (a3)
  371.  
  372.     moveq    #2,d0
  373.     and.b    $bfe001,d0
  374.     move.b    d0,P61_ofilter-P61_cn(a3)
  375.     bset    #1,$bfe001
  376.  
  377.     ifeq    system
  378.     ifne    exec
  379.     move.l    4.w,a6
  380.     moveq    #0,d0
  381.     btst    d0,297(a6)
  382.     beq.b    .no68010
  383.  
  384.     lea    P61_liko(pc),a5
  385.     jsr    -$1e(a6)
  386.  
  387. .no68010
  388.     move.l    d0,P61_VBR-P61_cn(a3)
  389.     endc
  390.  
  391.     move.l    P61_VBR-P61_cn(a3),a0
  392.     lea    $78(a0),a0
  393.     move.l    a0,P61_vektori-P61_cn(a3)
  394.  
  395.     move.l    (a0),P61_oldlev6-P61_cn(a3)
  396.     lea    P61_dmason(pc),a1
  397.     move.l    a1,(a0)
  398.     endc
  399.  
  400.     moveq    #0,d0
  401.     lea    $dff000,a6
  402.     move    d0,$a8(a6)
  403.     move    d0,$b8(a6)
  404.     move    d0,$c8(a6)
  405.     move    d0,$d8(a6)
  406.     move    #$f,$96(a6)
  407.  
  408.     ifeq    system
  409.     lea    P61_dmason(pc),a1
  410.     move.l    a1,(a0)
  411.     move    #$2000,$9a(a6)
  412.     lea    $bfd000,a0
  413.     lea    P61_timers(pc),a1
  414.     move.b    #$7f,$d00(a0)
  415.     move.b    #$10,$e00(a0)
  416.     move.b    #$10,$f00(a0)
  417.     move.b    $400(a0),(a1)+
  418.     move.b    $500(a0),(a1)+
  419.     move.b    $600(a0),(a1)+
  420.     move.b    $700(a0),(a1)
  421.     endc
  422.  
  423.     ifeq    system!CIA
  424.     move.b    #$82,$d00(a0)
  425.     endc
  426.  
  427.     ifne    CIA
  428.     move    (sp)+,d0
  429.     subq    #1,d0
  430.     beq.b    P61_ForcePAL
  431.     subq    #1,d0
  432.     beq.b    P61_NTSC
  433.     ifne    exec
  434.     move.l    4.w,a1
  435.     cmp.b    #60,$213(a1)    ;PowerSupplyFrequency
  436.     beq.b    P61_NTSC
  437.     endc
  438. P61_ForcePAL
  439.     move.l    #1773447,d0    ;PAL
  440.     bra.b    P61_setcia
  441. P61_NTSC
  442.     move.l    #1789773,d0    ;NTSC
  443. P61_setcia
  444.     move.l    d0,P61_timer-P61_cn(a3)
  445.     divu    #125,d0
  446.     move    d0,P61_thi2-P61_cn(a3)
  447.     sub    #$1f0*2,d0
  448.     move    d0,P61_thi-P61_cn(a3)
  449.  
  450.     ifeq    system
  451.     move    P61_thi2-P61_cn(a3),d0
  452.     move.b    d0,$400(a0)
  453.     lsr    #8,d0
  454.     move.b    d0,$500(a0)
  455.     lea    P61_intti(pc),a1
  456.     move.l    a1,P61_tintti-P61_cn(a3)
  457.     move.l    P61_vektori(pc),a2
  458.     move.l    a1,(a2)
  459.     move.b    #$83,$d00(a0)
  460.     move.b    #$11,$e00(a0)
  461.     endc
  462.     endc
  463.  
  464.     ifeq    system
  465.     move    #$e000,$9a(a6)
  466.     moveq    #0,d0
  467.     rts
  468.  
  469.     ifne    exec
  470. P61_liko
  471.     dc.l    $4E7A0801        ;MOVEC    VBR,d0
  472.     rte
  473.     endc
  474.     endc
  475.  
  476.     ifne    system
  477.     move.l    a6,-(sp)
  478.  
  479.     ifne    CIA
  480.     clr    P61_server-P61_cn(a3)
  481.     else
  482.     move    #1,P61_server-P61_cn(a3)
  483.     endc
  484.  
  485.     move.l    4.w,a6
  486.     moveq    #-1,d0
  487.     jsr    -$14a(a6)
  488.     move.b    d0,P61_sigbit-P61_cn(a3)
  489.     bmi    P61_err
  490.  
  491.     lea    P61_allocport(pc),a1
  492.     move.l    a1,P61_portti-P61_cn(a3)
  493.     move.b    d0,15(a1)
  494.     move.l    a1,-(sp)
  495.     suba.l    a1,a1
  496.     jsr    -$126(a6)
  497.     move.l    (sp)+,a1
  498.     move.l    d0,16(a1)
  499.     lea    P61_reqlist(pc),a0
  500.     move.l    a0,(a0)
  501.     addq.l    #4,(a0)
  502.     clr.l    4(a0)
  503.     move.l    a0,8(a0)
  504.  
  505.     lea    P61_dat(pc),a1
  506.     move.l    a1,P61_reqdata-P61_cn(a3)
  507.     lea    P61_allocreq(pc),a1
  508.     lea    P61_audiodev(pc),a0
  509.     moveq    #0,d0
  510.     moveq    #0,d1
  511.     jsr    -$1bc(a6)
  512.     tst.l    d0
  513.     bne    P61_err
  514.     st.b    P61_audioopen-P61_cn(a3)
  515.  
  516.     lea    P61_timerint(pc),a1
  517.     move.l    a1,P61_timerdata-P61_cn(a3)
  518.     lea    P61_lev6server(pc),a1
  519.     move.l    a1,P61_timerdata+8-P61_cn(a3)
  520.  
  521.     moveq    #0,d3
  522.     lea    P61_cianame(pc),a1
  523. P61_openciares
  524.     moveq    #0,d0
  525.     move.l    4.w,a6
  526.     jsr    -$1f2(a6)
  527.     move.l    d0,P61_ciares-P61_cn(a3)
  528.     beq.b    P61_err
  529.     move.l    d0,a6
  530.     lea    P61_timerinterrupt(pc),a1
  531.     moveq    #0,d0
  532.     jsr    -6(a6)
  533.     tst.l    d0
  534.     beq.b    P61_gottimer
  535.     addq.l    #4,d3
  536.     lea    P61_timerinterrupt(pc),a1
  537.     moveq    #1,d0
  538.     jsr    -6(a6)
  539.     tst.l    d0
  540.     bne.b    P61_err
  541.  
  542. P61_gottimer
  543.     lea    P61_craddr+8(pc),a6
  544.     move.l    P61_ciaaddr(pc,d3),d0
  545.     move.l    d0,(a6)
  546.     sub    #$100,d0
  547.     move.l    d0,-(a6)
  548.     moveq    #2,d3
  549.     btst    #9,d0
  550.     bne.b    P61_timerB
  551.     subq.b    #1,d3
  552.     add    #$100,d0
  553. P61_timerB
  554.     add    #$900,d0
  555.     move.l    d0,-(a6)
  556.     move.l    d0,a0
  557.     and.b    #%10000000,(a0)
  558.     move.b    d3,P61_timeropen-P61_cn(a3)
  559.     moveq    #0,d0
  560.     ifne    CIA
  561.     move.l    P61_craddr+4(pc),a1
  562.     move.b    P61_tlo(pc),(a1)
  563.     move.b    P61_thi(pc),$100(a1)
  564.     endc
  565.     or.b    #$19,(a0)
  566.     st    P61_timeron-P61_cn(a3)
  567. P61_pois
  568.     move.l    (sp)+,a6
  569.     rts
  570.  
  571. P61_err    moveq    #-1,d0
  572.     bra.b    P61_pois
  573.     rts
  574.  
  575. P61_ciaaddr
  576.     dc.l    $bfd500,$bfd700
  577.     endc
  578.  
  579. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  580. ;­         Call P61_End to stop the music        ­
  581. ;­   A6 --> Customchip baseaddress ($DFF000)    ­
  582. ;­        Uses D0/D1/A0/A1/A3        ­
  583. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  584.  
  585. P61_End    moveq    #0,d0
  586.     move    d0,$a8(a6)
  587.     move    d0,$b8(a6)
  588.     move    d0,$c8(a6)
  589.     move    d0,$d8(a6)
  590.     move    #$f,$96(a6)
  591.  
  592.     and.b    #~2,$bfe001
  593.     move.b    P61_ofilter(pc),d0
  594.     or.b    d0,$bfe001
  595.  
  596.     ifeq    system
  597.     move    #$2000,$9a(a6)
  598.     move.l    P61_vektori(pc),a0
  599.     move.l    P61_oldlev6(pc),(a0)
  600.     lea    $bfd000,a0
  601.     lea    P61_timers(pc),a1
  602.     move.b    (a1)+,$400(a0)
  603.     move.b    (a1)+,$500(a0)
  604.     move.b    (a1)+,$600(a0)
  605.     move.b    (a1)+,$700(a0)
  606.     move.b    #$10,$e00(a0)
  607.     move.b    #$10,$f00(a0)
  608.  
  609.     else
  610.  
  611.     clr    P61_timeron-P61_cn(a3)
  612.     move.l    a6,-(sp)
  613.     lea    P61_cn(pc),a3
  614.     moveq    #0,d0
  615.     move.b    P61_timeropen(pc),d0
  616.     beq.b    P61_rem1
  617.     move.l    P61_ciares(pc),a6
  618.     lea    P61_timerinterrupt(pc),a1
  619.     subq.b    #1,d0
  620.     jsr    -12(a6)
  621. P61_rem1
  622.     move.l    4.w,a6
  623.     tst.b    P61_audioopen-P61_cn(a3)
  624.     beq.b    P61_rem2
  625.     lea    P61_allocreq(pc),a1
  626.     jsr    -$1c2(a6)
  627.     clr.b    P61_audioopen-P61_cn(a3)
  628. P61_rem2
  629.     moveq    #0,d0
  630.     move.b    P61_sigbit(pc),d0
  631.     bmi.b    P61_rem3
  632.     jsr    -$150(a6)
  633.     st    P61_sigbit-P61_cn(a3)
  634. P61_rem3
  635.     move.l    (sp)+,a6
  636.     endc
  637.     rts
  638.  
  639.     ifne    fade
  640. P61_mfade
  641.     lea    P61_Master(pc),a0
  642.     move    (a0),d0
  643.     move.w    P61_FadeTo(pc),d1
  644.     cmp.w    d1,d0
  645.     beq.s    .skip
  646.     blt.s    .add
  647.     subq.w    #2,d0
  648. .add    addq.w    #1,d0
  649.     subq.w    #1,P61_FadeCount-P61_Master(a0)
  650.     bgt.s    .skip
  651.     move.w    P61_FadeSpeed-P61_Master(a0),P61_FadeCount-P61_Master(a0)
  652.     move.w    d0,(a0)
  653. .skip    move    P61_temp0+P61_Shadow(pc),d1
  654.     mulu    d0,d1
  655.     lsr    #6,d1
  656.     move    d1,$a8(a6)
  657.  
  658.     ifgt    channels-1
  659.     move    P61_temp1+P61_Shadow(pc),d1
  660.     mulu    d0,d1
  661.     lsr    #6,d1
  662.     move    d1,$b8(a6)
  663.     endc
  664.  
  665.     ifgt    channels-2
  666.     move    P61_temp2+P61_Shadow(pc),d1
  667.     mulu    d0,d1
  668.     lsr    #6,d1
  669.     move    d1,$c8(a6)
  670.     endc
  671.  
  672.     ifgt    channels-3
  673.     move    P61_temp3+P61_Shadow(pc),d1
  674.     mulu    d0,d1
  675.     lsr    #6,d1
  676.     move    d1,$d8(a6)
  677.     endc
  678.     rts
  679.     endc
  680.     
  681.  
  682. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  683. ;­ Call P61_SetPosition to jump to a specific    ­
  684. ;­          position in the song.        ­
  685. ;­ D0.l --> Position                ­
  686. ;­ Starts from the beginning if out of limits.    ­
  687. ;­              Uses A0/A1/A3/D0-D3        ­
  688. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  689.  
  690.     ifne    jump
  691. P61_SetPosition
  692.     lea    P61_cn(pc),a3
  693.     ifne    P61_pl
  694.     clr    P61_plflag-P61_cn(a3)
  695.     endc
  696.     moveq    #0,d1
  697.     move.b    d0,d1
  698.     move.l    d1,d0
  699.     cmp    P61_slen-P61_cn(a3),d0
  700.     blo.b    .e
  701.     moveq    #0,d0
  702. .e    move    d0,P61_Pos-P61_cn(a3)
  703.     add.l    P61_possibase(pc),d0
  704.     move.l    d0,P61_spos-P61_cn(a3)
  705.  
  706.     moveq    #64,d0
  707.     move    d0,P61_rowpos-P61_cn(a3)
  708.     clr    P61_CRow-P61_cn(a3)
  709.     move.l    P61_spos(pc),a1
  710.     move.l    P61_patternbase(pc),a0
  711.     addq    #1,P61_Pos-P61_cn(a3)
  712.     move.b    (a1)+,d0
  713.     move.l    a1,P61_spos-P61_cn(a3)
  714.     move.l    P61_positionbase(pc),a1
  715.     move    d0,P61_Patt-P61_cn(a3)
  716.     lsl    #3,d0
  717.     add.l    d0,a1
  718.     movem    (a1),d0-d3
  719.     lea    (a0,d0.l),a1
  720.     move    d1,d0
  721.     move.l    a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  722.     lea    (a0,d0.l),a1
  723.     move.l    a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  724.     move    d2,d0
  725.     lea    (a0,d0.l),a1
  726.     move.l    a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  727.     move    d3,d0
  728.     add.l    d0,a0
  729.     move.l    a0,P61_ChaPos+P61_temp3-P61_cn(a3)
  730.     rts
  731.     endc
  732.  
  733. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  734. ;­ Call P61_Music every frame to play the music    ­
  735. ;­      _NOT_ if CIA-version is used!        ­
  736. ;­ A6 --> Customchip baseaddress ($DFF000)    ­
  737. ;­              Uses A0-A5/D0-D7        ­
  738. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  739.  
  740. P61_Music
  741.     lea    P61_cn(pc),a3
  742.  
  743.     tst    P61_Play-P61_cn(a3)
  744.     bne.b    P61_ohitaaa
  745.     ifne    CIA
  746.     ifne    system
  747.     move.l    P61_craddr+4(pc),a0
  748.     move.b    P61_tlo2(pc),(a0)
  749.     move.b    P61_thi2(pc),$100(a0)
  750.     endc
  751.     endc
  752.     rts
  753.  
  754. P61_ohitaaa
  755.     ifne    fade
  756.     pea    P61_mfade(pc)
  757.     endc
  758.  
  759.     moveq    #Channel_Block_SIZE,d6
  760.     moveq    #16,d7
  761.  
  762.     move    (a3),d4
  763.     addq    #1,d4
  764.     cmp    P61_speed(pc),d4
  765.     beq    P61_playtime
  766.  
  767.     move    d4,(a3)
  768.  
  769. P61_delay
  770.     ifne    CIA
  771.     ifne    system
  772.     move.l    P61_craddr+4(pc),a0
  773.     move.b    P61_tlo2(pc),(a0)
  774.     move.b    P61_thi2(pc),$100(a0)
  775.     endc
  776.     endc
  777.  
  778.     lea    P61_temp0(pc),a5
  779.     lea    $a0(a6),a4
  780.  
  781.     moveq    #channels-1,d5
  782. P61_lopas
  783.     tst    P61_OnOff(a5)
  784.     beq    P61_contfxdone
  785.     moveq    #$f,d0
  786.     and    (a5),d0
  787.     ifeq    opt020
  788.     add    d0,d0
  789.     move    P61_jtab2(pc,d0),d0
  790.     else
  791.     move    P61_jtab2(pc,d0*2),d0
  792.     endc
  793.     jmp    P61_jtab2(pc,d0)
  794.  
  795. P61_jtab2
  796.     dc    P61_contfxdone-P61_jtab2
  797.  
  798.     ifne    P61_pu
  799.     dc    P61_portup-P61_jtab2
  800.     else
  801.     dc    P61_contfxdone-P61_jtab2
  802.     endc
  803.  
  804.     ifne    P61_pd
  805.     dc    P61_portdwn-P61_jtab2
  806.     else
  807.     dc    P61_contfxdone-P61_jtab2
  808.     endc
  809.  
  810.     ifne    P61_tp
  811.     dc    P61_toneport-P61_jtab2
  812.     else
  813.     dc    P61_contfxdone-P61_jtab2
  814.     endc
  815.  
  816.     ifne    P61_vib
  817.     dc    P61_vib2-P61_jtab2
  818.     else
  819.     dc    P61_contfxdone-P61_jtab2
  820.     endc
  821.  
  822.     ifne    P61_tpvs
  823.     dc    P61_tpochvslide-P61_jtab2
  824.     else
  825.     dc    P61_contfxdone-P61_jtab2
  826.     endc
  827.  
  828.     ifne    P61_vbvs
  829.     dc    P61_vibochvslide-P61_jtab2
  830.     else
  831.     dc    P61_contfxdone-P61_jtab2
  832.     endc
  833.  
  834.     ifne    P61_tre
  835.     dc    P61_tremo-P61_jtab2
  836.     else
  837.     dc    P61_contfxdone-P61_jtab2
  838.     endc
  839.  
  840.     ifne    P61_arp
  841.     dc    P61_arpeggio-P61_jtab2
  842.     else
  843.     dc    P61_contfxdone-P61_jtab2
  844.     endc
  845.  
  846.     dc    P61_contfxdone-P61_jtab2
  847.  
  848.     ifne    P61_vs
  849.     dc    P61_volslide-P61_jtab2
  850.     else
  851.     dc    P61_contfxdone-P61_jtab2
  852.     endc
  853.  
  854.     dc    P61_contfxdone-P61_jtab2
  855.     dc    P61_contfxdone-P61_jtab2
  856.     dc    P61_contfxdone-P61_jtab2
  857.  
  858.     ifne    P61_ec
  859.     dc    P61_contecommands-P61_jtab2
  860.     else
  861.     dc    P61_contfxdone-P61_jtab2
  862.     endc
  863.     dc    P61_contfxdone-P61_jtab2
  864.  
  865.     ifne    P61_ec
  866. P61_contecommands
  867.     move.b    P61_Info(a5),d0
  868.     and    #$f0,d0
  869.     lsr    #3,d0
  870.     move    P61_etab2(pc,d0),d0
  871.     jmp    P61_etab2(pc,d0)
  872.  
  873. P61_etab2
  874.     dc    P61_contfxdone-P61_etab2
  875.  
  876.     ifne    P61_fsu
  877.     dc    P61_fineup2-P61_etab2
  878.     else
  879.     dc    P61_contfxdone-P61_etab2
  880.     endc
  881.  
  882.     ifne    P61_fsd
  883.     dc    P61_finedwn2-P61_etab2
  884.     else
  885.     dc    P61_contfxdone-P61_etab2
  886.     endc
  887.  
  888.     dc    P61_contfxdone-P61_etab2
  889.     dc    P61_contfxdone-P61_etab2
  890.  
  891.     dc    P61_contfxdone-P61_etab2
  892.     dc    P61_contfxdone-P61_etab2
  893.  
  894.     dc    P61_contfxdone-P61_etab2
  895.     dc    P61_contfxdone-P61_etab2
  896.  
  897.     ifne    P61_rt
  898.     dc    P61_retrig-P61_etab2
  899.     else
  900.     dc    P61_contfxdone-P61_etab2
  901.     endc
  902.  
  903.     ifne    P61_fvu
  904.     dc    P61_finevup2-P61_etab2
  905.     else
  906.     dc    P61_contfxdone-P61_etab2
  907.     endc
  908.  
  909.     ifne    P61_fvd
  910.     dc    P61_finevdwn2-P61_etab2
  911.     else
  912.     dc    P61_contfxdone-P61_etab2
  913.     endc
  914.  
  915.     ifne    P61_nc
  916.     dc    P61_notecut-P61_etab2
  917.     else
  918.     dc    P61_contfxdone-P61_etab2
  919.     endc
  920.  
  921.     ifne    P61_nd
  922.     dc    P61_notedelay-P61_etab2
  923.     else
  924.     dc    P61_contfxdone-P61_etab2
  925.     endc
  926.  
  927.     dc    P61_contfxdone-P61_etab2
  928.     dc    P61_contfxdone-P61_etab2
  929.     endc
  930.  
  931.     ifne    P61_fsu
  932. P61_fineup2
  933.     tst    (a3)
  934.     bne    P61_contfxdone
  935.     moveq    #$f,d0
  936.     and.b    P61_Info(a5),d0
  937.     sub    d0,P61_Period(a5)
  938.     moveq    #113,d0
  939.     cmp    P61_Period(a5),d0
  940.     ble.b    .jup
  941.     move    d0,P61_Period(a5)
  942. .jup    move    P61_Period(a5),6(a4)
  943.     bra    P61_contfxdone
  944.     endc
  945.  
  946.     ifne    P61_fsd
  947. P61_finedwn2
  948.     tst    (a3)
  949.     bne    P61_contfxdone
  950.     moveq    #$f,d0
  951.     and.b    P61_Info(a5),d0
  952.     add    d0,P61_Period(a5)
  953.     cmp    #856,P61_Period(a5)
  954.     ble.b    .jup
  955.     move    #856,P61_Period(a5)
  956. .jup    move    P61_Period(a5),6(a4)
  957.     bra    P61_contfxdone
  958.     endc
  959.  
  960.     ifne    P61_fvu
  961. P61_finevup2
  962.     tst    (a3)
  963.     bne    P61_contfxdone
  964.     moveq    #$f,d0
  965.     and.b    P61_Info(a5),d0
  966.     add    d0,P61_Volume(a5)
  967.     moveq    #64,d0
  968.     cmp    P61_Volume(a5),d0
  969.     bge.b    .jup
  970.     move    d0,P61_Volume(a5)
  971. .jup    move    P61_Volume(a5),8(a4)
  972.     bra    P61_contfxdone
  973.     endc
  974.  
  975.     ifne    P61_fvd
  976. P61_finevdwn2
  977.     tst    (a3)
  978.     bne    P61_contfxdone
  979.     moveq    #$f,d0
  980.     and.b    P61_Info(a5),d0
  981.     sub    d0,P61_Volume(a5)
  982.     bpl.b    .jup
  983.     clr    P61_Volume(a5)
  984. .jup    move    P61_Volume(a5),8(a4)
  985.     bra    P61_contfxdone
  986.     endc
  987.  
  988.     ifne    P61_nc
  989. P61_notecut
  990.     moveq    #$f,d0
  991.     and.b    P61_Info(a5),d0
  992.     cmp    (a3),d0
  993.     bne    P61_contfxdone
  994.     ifeq    fade
  995.     clr    8(a4)
  996.     else
  997.     clr    P61_Shadow(a5)
  998.     endc
  999.     clr    P61_Volume(a5)
  1000.     bra    P61_contfxdone
  1001.     endc
  1002.  
  1003.     ifne    P61_nd
  1004. P61_notedelay
  1005.     moveq    #$f,d0
  1006.     and.b    P61_Info(a5),d0
  1007.     cmp    (a3),d0
  1008.     bne    P61_contfxdone
  1009.  
  1010.     moveq    #$7e,d0
  1011.     and.b    (a5),d0
  1012.     beq    P61_contfxdone
  1013.     move    P61_DMABit(a5),d0
  1014.     move    d0,$96(a6)
  1015.     or    d0,P61_dma-P61_cn(a3)
  1016.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1017.     move.l    (a1)+,(a4)+            ;Pointer
  1018.     move    (a1),(a4)+            ;Length
  1019.     move    P61_Period(a5),(a4)
  1020.     subq.l    #6,a4
  1021.  
  1022.     ifeq    system
  1023.     lea    P61_dmason(pc),a1
  1024.     move.l    P61_vektori(pc),a0
  1025.     move.l    a1,(a0)
  1026.     move.b    #$f0,$bfd600
  1027.     move.b    #$01,$bfd700
  1028.     move.b    #$19,$bfdf00
  1029.     else
  1030.     move    #1,P61_server-P61_cn(a3)
  1031.     move.l    P61_craddr+4(pc),a1
  1032.     move.b    #$f0,(a1)
  1033.     move.b    #1,$100(a1)
  1034.     endc
  1035.     bra    P61_contfxdone
  1036.     endc
  1037.  
  1038.     ifne    P61_rt
  1039. P61_retrig
  1040.     subq    #1,P61_RetrigCount(a5)
  1041.     bne    P61_contfxdone
  1042.     move    P61_DMABit(a5),d0
  1043.     move    d0,$96(a6)
  1044.     or    d0,P61_dma-P61_cn(a3)
  1045.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1046.     move.l    (a1)+,(a4)            ;Pointer
  1047.     move    (a1),4(a4)            ;Length
  1048.  
  1049.     ifeq    system
  1050.     lea    P61_dmason(pc),a1
  1051.     move.l    P61_vektori(pc),a0
  1052.     move.l    a1,(a0)
  1053.     move.b    #$f0,$bfd600
  1054.     move.b    #$01,$bfd700
  1055.     move.b    #$19,$bfdf00
  1056.     else
  1057.     move    #1,P61_server-P61_cn(a3)
  1058.     move.l    P61_craddr+4(pc),a1
  1059.     move.b    #$f0,(a1)
  1060.     move.b    #1,$100(a1)
  1061.     endc
  1062.  
  1063.     moveq    #$f,d0
  1064.     and.b    P61_Info(a5),d0
  1065.     move    d0,P61_RetrigCount(a5)
  1066.     bra    P61_contfxdone
  1067.     endc
  1068.  
  1069.     ifne    P61_arp
  1070. P61_arplist
  1071.  dc.b 0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1
  1072.  
  1073. P61_arpeggio
  1074.     move    (a3),d0
  1075.     move.b    P61_arplist(pc,d0),d0
  1076.     beq.b    .arp0
  1077.     bmi.b    .arp1
  1078.  
  1079.     move.b    P61_Info(a5),d0
  1080.     lsr    #4,d0
  1081.     bra.b    .arp3
  1082.  
  1083. .arp0    move    P61_Note(a5),d0
  1084.     move    P61_periods(pc,d0),6(a4)
  1085.     bra    P61_contfxdone
  1086.  
  1087. .arp1    moveq    #$f,d0
  1088.     and.b    P61_Info(a5),d0
  1089.  
  1090. .arp3    add    d0,d0
  1091.     add    P61_Note(a5),d0
  1092.     move    P61_periods(pc,d0),6(a4)
  1093.     bra    P61_contfxdone
  1094.     endc
  1095.  
  1096. P61_periods
  1097.     ifne    P61_ft
  1098.     incbin    "data/p61a.periods"
  1099.     else
  1100.     incbin    "data/p61a.periods.nft"
  1101.     endc
  1102.  
  1103.     ifne    P61_vs
  1104. P61_volslide
  1105.     move.b    P61_Info(a5),d0
  1106.     sub.b    d0,P61_Volume+1(a5)
  1107.     bpl.b    .test
  1108.     clr    P61_Volume(a5)
  1109.     ifeq    fade
  1110.     clr    8(a4)
  1111.     else
  1112.     clr    P61_Shadow(a5)
  1113.     endc
  1114.     bra    P61_contfxdone
  1115. .test    moveq    #64,d0
  1116.     cmp    P61_Volume(a5),d0
  1117.     bge.b    .ncs
  1118.     move    d0,P61_Volume(a5)
  1119.     ifeq    fade
  1120.     move    d0,8(a4)
  1121.     else
  1122.     move    d0,P61_Shadow(a5)
  1123.     endc
  1124.     bra.b    P61_contfxdone
  1125. .ncs
  1126.     ifeq    fade
  1127.     move    P61_Volume(a5),8(a4)
  1128.     else
  1129.     move    P61_Volume(a5),P61_Shadow(a5)
  1130.     endc
  1131.     bra.b    P61_contfxdone
  1132.     endc
  1133.  
  1134.     ifne    P61_tpvs
  1135. P61_tpochvslide
  1136.     move.b    P61_Info(a5),d0
  1137.     sub.b    d0,P61_Volume+1(a5)
  1138.     bpl.b    .test
  1139.     clr    P61_Volume(a5)
  1140.     ifeq    fade
  1141.     clr    8(a4)
  1142.     else
  1143.     clr    P61_Shadow(a5)
  1144.     endc
  1145.     bra.b    P61_toneport
  1146. .test    moveq    #64,d0
  1147.     cmp    P61_Volume(a5),d0
  1148.     bge.b    .ncs
  1149.     move    d0,P61_Volume(a5)
  1150. .ncs
  1151.     ifeq    fade
  1152.     move    P61_Volume(a5),8(a4)
  1153.     else
  1154.     move    P61_Volume(a5),P61_Shadow(a5)
  1155.     endc
  1156.     endc
  1157.  
  1158.     ifne    P61_tp
  1159. P61_toneport
  1160.     move    P61_ToPeriod(a5),d0
  1161.     beq.b    P61_contfxdone
  1162.     move    P61_TPSpeed(a5),d1
  1163.     cmp    P61_Period(a5),d0
  1164.     blt.b    .topoup
  1165.  
  1166.     add    d1,P61_Period(a5)
  1167.     cmp    P61_Period(a5),d0
  1168.     bgt.b    .setper
  1169.     move    d0,P61_Period(a5)
  1170.     clr    P61_ToPeriod(a5)
  1171.     move    d0,6(a4)
  1172.     bra.b    P61_contfxdone
  1173.  
  1174. .topoup
  1175.     sub    d1,P61_Period(a5)
  1176.     cmp    P61_Period(a5),d0
  1177.     blt.b    .setper
  1178.     move    d0,P61_Period(a5)
  1179.     clr    P61_ToPeriod(a5)
  1180. .setper
  1181.     move    P61_Period(a5),6(a4)
  1182.     else
  1183.     nop
  1184.     endc
  1185.  
  1186. P61_contfxdone
  1187.     ifne    P61_il
  1188.     bsr    P61_funk2
  1189.     endc
  1190.  
  1191.     add.l    d6,a5
  1192.     add.l    d7,a4
  1193.     dbf    d5,P61_lopas
  1194.  
  1195.     cmp    P61_speed2(pc),d4
  1196.     beq.b    P61_preplay
  1197.     rts
  1198.  
  1199.     ifne    P61_pu
  1200. P61_portup
  1201.     moveq    #0,D0
  1202.     move.b    P61_Info(a5),d0
  1203.     sub    d0,P61_Period(a5)
  1204.     moveq    #113,d0
  1205.     cmp    P61_Period(a5),d0
  1206.     ble.b    .skip
  1207.     move    d0,P61_Period(a5)
  1208.     move    d0,6(a4)
  1209.     bra.b    P61_contfxdone
  1210. .skip
  1211.     move    P61_Period(a5),6(a4)
  1212.     bra.b    P61_contfxdone
  1213.     endc
  1214.  
  1215.     ifne    P61_pd
  1216. P61_portdwn
  1217.     moveq    #0,d0
  1218.     move.b    P61_Info(a5),d0
  1219.     add    d0,P61_Period(a5)
  1220.     cmp    #856,P61_Period(a5)
  1221.     ble.b    .skip
  1222.     move    #856,d0
  1223.     move    d0,P61_Period(a5)
  1224.     move    d0,6(a4)
  1225.     bra.b    P61_contfxdone
  1226. .skip
  1227.     move    P61_Period(a5),6(a4)
  1228.     bra.b    P61_contfxdone
  1229.     endc
  1230.  
  1231.     ifne    P61_pde
  1232. P61_return
  1233.     rts
  1234.  
  1235. P61_preplay
  1236.     tst    P61_pdflag-P61_cn(a3)
  1237.     bne.b    P61_return
  1238.     else
  1239. P61_preplay
  1240.     endc
  1241.  
  1242.     lea    P61_temp0(pc),a5
  1243.     lea    P61_samples-16(pc),a0
  1244.  
  1245.     moveq    #channels-1,d5
  1246. P61_loaps
  1247.     ifne    P61_pl
  1248.     lea    P61_TData(a5),a1
  1249.     move    2(a5),(a1)+
  1250.     move.l    P61_ChaPos(a5),(a1)+
  1251.     move.l    P61_TempPos(a5),(a1)+
  1252.     move    P61_TempLen(a5),(a1)
  1253.     endc
  1254.  
  1255.     move.b    P61_Pack(a5),d0
  1256.     and.b    #$3f,d0
  1257.     beq.b    P61_takeone
  1258.  
  1259.     tst.b    P61_Pack(a5)
  1260.     bmi.b    .keepsame
  1261.  
  1262.     subq.b    #1,P61_Pack(a5)
  1263.     clr    P61_OnOff(a5)            ; Empty row
  1264.     add.l    d6,a5
  1265.     dbf    d5,P61_loaps
  1266.     rts
  1267.  
  1268. .keepsame
  1269.     subq.b    #1,P61_Pack(a5)
  1270.     bra    P61_dko
  1271.  
  1272. P61_takeone
  1273.     tst.b    P61_TempLen+1(a5)
  1274.     beq.b    P61_takenorm
  1275.  
  1276.     subq.b    #1,P61_TempLen+1(a5)
  1277.     move.l    P61_TempPos(a5),a2
  1278.  
  1279. P61_jedi
  1280.     move.b    (a2)+,d0
  1281.     moveq    #%01100000,d1
  1282.     and.b    d0,d1
  1283.     cmp.b    #%01100000,d1
  1284.     bne.b    .all
  1285.  
  1286.     moveq    #%01110000,d1
  1287.     and.b    d0,d1
  1288.     cmp.b    #%01110000,d1
  1289.     bne.b    .cmd
  1290.  
  1291.     moveq    #%01111000,d1
  1292.     and.b    d0,d1
  1293.     cmp.b    #%01111000,d1
  1294.     bne.b    .note
  1295.  
  1296. .empty    clr    P61_OnOff(a5)            ; Empty row
  1297.     clr    (a5)+
  1298.     clr.b    (a5)+
  1299.     tst.b    d0
  1300.     bpl.b    .ex
  1301.     move.b    (a2)+,(a5)            ; Compression info
  1302.     bra.b    .ex
  1303.  
  1304. .all    move.b    d0,(a5)+
  1305.     ifeq    opt020
  1306.     move.b    (a2)+,(a5)+
  1307.     move.b    (a2)+,(a5)+
  1308.     else
  1309.     move    (a2)+,(a5)+
  1310.     endc
  1311.     tst.b    d0
  1312.     bpl.b    .ex
  1313.     move.b    (a2)+,(a5)            ; Compression info
  1314.     bra.b    .ex
  1315.  
  1316. .cmd    moveq    #$f,d1
  1317.     and    d0,d1
  1318.     move    d1,(a5)+            ; cmd
  1319.     move.b    (a2)+,(a5)+            ; info
  1320.     tst.b    d0
  1321.     bpl.b    .ex
  1322.     move.b    (a2)+,(a5)            ; Compression info
  1323.     bra.b    .ex
  1324.  
  1325. .note    moveq    #7,d1
  1326.     and    d0,d1
  1327.     lsl    #8,d1
  1328.     move.b    (a2)+,d1
  1329.     lsl    #4,d1
  1330.     move    d1,(a5)+
  1331.     clr.b    (a5)+    
  1332.     tst.b    d0
  1333.     bpl.b    .ex
  1334.     move.b    (a2)+,(a5)            ; Compression info
  1335. .ex    subq.l    #3,a5
  1336.     move.l    a2,P61_TempPos(a5)
  1337.     bra    P61_dko
  1338.  
  1339.  
  1340. P61_takenorm
  1341.     move.l    P61_ChaPos(a5),a2
  1342.  
  1343.     move.b    (a2)+,d0
  1344.     moveq    #%01100000,d1
  1345.     and.b    d0,d1
  1346.     cmp.b    #%01100000,d1
  1347.     bne.b    .all
  1348.  
  1349.     moveq    #%01110000,d1
  1350.     and.b    d0,d1
  1351.     cmp.b    #%01110000,d1
  1352.     bne.b    .cmd
  1353.  
  1354.     moveq    #%01111000,d1
  1355.     and.b    d0,d1
  1356.     cmp.b    #%01111000,d1
  1357.     bne.b    .note
  1358.  
  1359. .empty    clr    P61_OnOff(a5)            ; Empty row
  1360.     clr    (a5)+
  1361.     clr.b    (a5)+
  1362.     tst.b    d0
  1363.     bpl.b    .proccomp
  1364.     move.b    (a2)+,(a5)            ; Compression info
  1365.     bra.b    .proccomp
  1366.  
  1367.  
  1368. .all    move.b    d0,(a5)+
  1369.     ifeq    opt020
  1370.     move.b    (a2)+,(a5)+
  1371.     move.b    (a2)+,(a5)+
  1372.     else
  1373.     move    (a2)+,(a5)+
  1374.     endc
  1375.     tst.b    d0
  1376.     bpl.b    .proccomp
  1377.     move.b    (a2)+,(a5)            ; Compression info
  1378.     bra.b    .proccomp
  1379.  
  1380. .cmd    moveq    #$f,d1
  1381.     and    d0,d1
  1382.     move    d1,(a5)+            ; cmd
  1383.     move.b    (a2)+,(a5)+            ; info
  1384.     tst.b    d0
  1385.     bpl.b    .proccomp
  1386.     move.b    (a2)+,(a5)            ; Compression info
  1387.     bra.b    .proccomp
  1388.  
  1389. .note    moveq    #7,d1
  1390.     and    d0,d1
  1391.     lsl    #8,d1
  1392.     move.b    (a2)+,d1
  1393.     lsl    #4,d1
  1394.     move    d1,(a5)+
  1395.     clr.b    (a5)+    
  1396.     tst.b    d0
  1397.     bpl.b    .proccomp
  1398.     move.b    (a2)+,(a5)            ; Compression info
  1399.  
  1400. .proccomp
  1401.     subq.l    #3,a5
  1402.     move.l    a2,P61_ChaPos(a5)
  1403.  
  1404.     tst.b    d0
  1405.     bpl.b    P61_dko
  1406.  
  1407.     move.b    3(a5),d0
  1408.     move.b    d0,d1
  1409.     and    #%11000000,d1
  1410.     beq.b    P61_dko                ; Empty datas
  1411.     cmp.b    #%10000000,d1
  1412.     beq.b    P61_dko                ; Same datas
  1413.  
  1414.     clr.b    3(a5)
  1415.     and    #$3f,d0
  1416.     move.b    d0,P61_TempLen+1(a5)
  1417.  
  1418.     cmp.b    #%11000000,d1
  1419.     beq.b    .bit16                ; 16-bit
  1420.  
  1421.     moveq    #0,d0                ; 8-bit
  1422.     move.b    (a2)+,d0
  1423.     move.l    a2,P61_ChaPos(a5)
  1424.     sub.l    d0,a2
  1425.     bra    P61_jedi
  1426.  
  1427. .bit16    moveq    #0,d0
  1428.     ifeq    opt020
  1429.     move.b    (a2)+,d0
  1430.     lsl    #8,d0
  1431.     move.b    (a2)+,d0
  1432.     else
  1433.     move    (a2)+,d0
  1434.     endc
  1435.  
  1436.     move.l    a2,P61_ChaPos(a5)
  1437.     sub.l    d0,a2
  1438.     bra    P61_jedi
  1439.  
  1440.  
  1441. P61_dko    st    P61_OnOff(a5)
  1442.     move    (a5),d0
  1443.     and    #$1f0,d0
  1444.     beq.b    .koto
  1445.     lea    (a0,d0),a1
  1446.     move.l    a1,P61_Sample(a5)
  1447.     ifne    P61_ft
  1448.     move.l    P61_SampleVolume(a1),P61_Volume(a5)
  1449.     else
  1450.     move    P61_SampleVolume(a1),P61_Volume(a5)
  1451.     endc
  1452.     ifne    P61_il
  1453.     move.l    P61_RepeatOffset(a1),P61_Wave(a5)
  1454.     endc
  1455.     ifne    P61_sof
  1456.     clr    P61_Offset(a5)
  1457.     endc
  1458.  
  1459. .koto    add.l    d6,a5
  1460.     dbf    d5,P61_loaps
  1461.     rts
  1462.  
  1463. P61_playtime
  1464.     clr    (a3)
  1465.  
  1466.     ifne    P61_pde
  1467.     tst    P61_pdelay-P61_cn(a3)
  1468.     beq.b    .djdj
  1469.     subq    #1,P61_pdelay-P61_cn(a3)
  1470.     bne    P61_delay
  1471.     tst    P61_speedis1-P61_cn(a3)
  1472.     bne    P61_delay
  1473.     clr    P61_pdflag-P61_cn(a3)
  1474.     bra    P61_delay
  1475. .djdj
  1476.     clr    P61_pdflag-P61_cn(a3)
  1477.     endc
  1478.  
  1479.     tst    P61_speedis1-P61_cn(a3)
  1480.     beq.b    .mo
  1481.     bsr    P61_preplay
  1482.  
  1483. .mo    lea    P61_temp0(pc),a5
  1484.     lea    $a0(a6),a4
  1485.  
  1486.     ifeq    system
  1487.     lea    P61_dmason(pc),a1
  1488.     move.l    P61_vektori(pc),a0
  1489.     move.l    a1,(a0)
  1490.     move.b    #$f0,$bfd600
  1491.     move.b    #$01,$bfd700
  1492.     move.b    #$19,$bfdf00
  1493.     else
  1494.     move    #1,P61_server-P61_cn(a3)
  1495.     move.l    P61_craddr+4(pc),a1
  1496.     move.b    #$f0,(a1)
  1497.     move.b    #1,$100(a1)
  1498.     endc
  1499.  
  1500.     lea    P61_periods(pc),a2
  1501.  
  1502.     moveq    #0,d4
  1503.     moveq    #channels-1,d5
  1504. P61_los    tst    P61_OnOff(a5)
  1505.     beq.b    P61_nocha
  1506.  
  1507.     moveq    #$f,d0
  1508.     and    (a5),d0
  1509.     lea    P61_jtab(pc),a1
  1510.     add    d0,d0
  1511.     add.l    d0,a1
  1512.     add    (a1),a1
  1513.     jmp    (a1)
  1514.  
  1515. P61_fxdone
  1516.     moveq    #$7e,d0
  1517.     and.b    (a5),d0
  1518.     beq.b    P61_nocha
  1519.     ifne    P61_vib
  1520.     clr.b    P61_VibPos(a5)
  1521.     endc
  1522.     ifne    P61_tre
  1523.     clr.b    P61_TrePos(a5)
  1524.     endc
  1525.  
  1526.      ifne    P61_ft
  1527.     add    P61_Fine(a5),d0
  1528.     endc
  1529.     move    d0,P61_Note(a5)
  1530.     move    (a2,d0),P61_Period(a5)
  1531.  
  1532. P61_zample
  1533.     ifne    P61_sof
  1534.     tst    P61_Offset(a5)
  1535.     bne    P61_pek
  1536.     endc
  1537.  
  1538.     or    P61_DMABit(a5),d4
  1539.     move    d4,$96(a6)
  1540.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1541.     move.l    (a1)+,(a4)            ;Pointer
  1542.     move    (a1),4(a4)            ;Length
  1543.  
  1544. P61_nocha
  1545.     ifeq    fade
  1546.     move.l    P61_Period(a5),6(a4)
  1547.     else
  1548.     move    P61_Period(a5),6(a4)
  1549.     move    P61_Volume(a5),P61_Shadow(a5)
  1550.     endc
  1551.  
  1552. P61_skip
  1553.     ifne    P61_il
  1554.     bsr    P61_funk2
  1555.     endc
  1556.  
  1557.     add.l    d6,a5
  1558.     add.l    d7,a4
  1559.     dbf    d5,P61_los
  1560.  
  1561.     move.b    d4,P61_dma+1-P61_cn(a3)
  1562.  
  1563.     ifne    P61_pl
  1564.     tst.b    P61_plflag+1-P61_cn(a3)
  1565.     beq.b    P61_ohittaa
  1566.  
  1567.     lea    P61_temp0(pc),a1
  1568.     lea    P61_looppos(pc),a0
  1569.     moveq    #channels-1,d0
  1570. .talt    move.b    1(a0),3(a1)
  1571.     addq.l    #2,a0
  1572.     move.l    (a0)+,P61_ChaPos(a1)
  1573.     move.l    (a0)+,P61_TempPos(a1)
  1574.     move    (a0)+,P61_TempLen(a1)
  1575.     add.l    d6,a1
  1576.     dbf    d0,.talt
  1577.  
  1578.     move    P61_plrowpos(pc),P61_rowpos-P61_cn(a3)
  1579.     clr.b    P61_plflag+1-P61_cn(a3)
  1580.     moveq    #63,d0
  1581.     sub    P61_rowpos-P61_cn(a3),d0
  1582.     move    d0,P61_CRow-P61_cn(a3)
  1583.     rts
  1584.     endc
  1585.  
  1586. P61_ohittaa
  1587.     subq    #1,P61_rowpos-P61_cn(a3)
  1588.     bmi.b    P61_nextpattern
  1589.     moveq    #63,d0
  1590.     sub    P61_rowpos-P61_cn(a3),d0
  1591.     move    d0,P61_CRow-P61_cn(a3)
  1592.     rts
  1593.  
  1594. P61_nextpattern
  1595.     ifne    P61_pl
  1596.     clr    P61_plflag-P61_cn(a3)
  1597.     endc
  1598.     move.l    P61_patternbase(pc),a4
  1599.     moveq    #63,d0
  1600.     move    d0,P61_rowpos-P61_cn(a3)
  1601.     clr    P61_CRow-P61_cn(a3)
  1602.     move.l    P61_spos(pc),a1
  1603.     addq    #1,P61_Pos-P61_cn(a3)
  1604.     move.b    (a1)+,d0
  1605.     bpl.b    P61_dk
  1606.     move.l    P61_possibase(pc),a1
  1607.     move.b    (a1)+,d0
  1608.     clr    P61_Pos-P61_cn(a3)
  1609.     move.w    #-2,P61_E8-P61_cn(a3)        ;songend
  1610. P61_dk    move.l    a1,P61_spos-P61_cn(a3)
  1611.     move    d0,P61_Patt-P61_cn(a3)
  1612.     lsl    #3,d0
  1613.     move.l    P61_positionbase(pc),a1
  1614.     add.l    d0,a1
  1615.  
  1616.     move    (a1)+,d0
  1617.     lea    (a4,d0.l),a2
  1618.     move.l    a2,P61_ChaPos+P61_temp0-P61_cn(a3)
  1619.     move    (a1)+,d0
  1620.     lea    (a4,d0.l),a2
  1621.     move.l    a2,P61_ChaPos+P61_temp1-P61_cn(a3)
  1622.     move    (a1)+,d0
  1623.     lea    (a4,d0.l),a2
  1624.     move.l    a2,P61_ChaPos+P61_temp2-P61_cn(a3)
  1625.     move    (a1),d0
  1626.     add.l    d0,a4
  1627.     move.l    a4,P61_ChaPos+P61_temp3-P61_cn(a3)
  1628.     rts
  1629.  
  1630.     ifne    P61_tp
  1631. P61_settoneport
  1632.     move.b    P61_Info(a5),d0
  1633.     beq.b    P61_toponochange
  1634.     move.b    d0,P61_TPSpeed+1(a5)
  1635. P61_toponochange
  1636.     moveq    #$7e,d0
  1637.     and.b    (a5),d0
  1638.     beq    P61_nocha
  1639.     add    P61_Fine(a5),d0
  1640.     move    d0,P61_Note(a5)
  1641.     move    (a2,d0),P61_ToPeriod(a5)
  1642.     bra    P61_nocha
  1643.     endc
  1644.  
  1645.     ifne    P61_sof
  1646. P61_sampleoffse
  1647.     moveq    #0,d1
  1648.     move    #$ff00,d1
  1649.     and    2(a5),d1
  1650.     bne.b    .deq
  1651.     move    P61_LOffset(a5),d1
  1652. .deq    move    d1,P61_LOffset(a5)
  1653.     add    d1,P61_Offset(a5)
  1654.  
  1655.     moveq    #$7e,d0
  1656.     and.b    (a5),d0
  1657.     beq    P61_nocha
  1658.  
  1659.     move    P61_Offset(a5),d2
  1660.     add    d1,P61_Offset(a5)        ; THIS IS A PT-FEATURE!
  1661.     move    d2,d1
  1662.  
  1663.     ifne    P61_vib
  1664.     clr.b    P61_VibPos(a5)
  1665.     endc
  1666.     ifne    P61_tre
  1667.     clr.b    P61_TrePos(a5)
  1668.     endc
  1669.  
  1670.     ifne    P61_ft
  1671.     add    P61_Fine(a5),d0
  1672.     endc
  1673.     move    d0,P61_Note(a5)
  1674.     move    (a2,d0),P61_Period(a5)
  1675.     bra.b    P61_hup
  1676.  
  1677. P61_pek    moveq    #0,d1
  1678.     move    P61_Offset(a5),d1
  1679. P61_hup    or    P61_DMABit(a5),d4
  1680.     move    d4,$96(a6)
  1681.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1682.     move.l    (a1)+,d0
  1683.     add.l    d1,d0
  1684.     move.l    d0,(a4)                ;Pointer
  1685.     lsr    #1,d1
  1686.     move    (a1),d0
  1687.     sub    d1,d0
  1688.     bpl.b    P61_offok
  1689.     move.l    -4(a1),(a4)            ;Pointer is over the end
  1690.     moveq    #1,d0
  1691. P61_offok
  1692.     move    d0,4(a4)            ;Length
  1693.     bra    P61_nocha
  1694.     endc
  1695.  
  1696.     ifne    P61_vl
  1697. P61_volum
  1698.     move.b    P61_Info(a5),P61_Volume+1(a5)
  1699.     bra    P61_fxdone
  1700.     endc
  1701.  
  1702.     ifne    P61_pj
  1703. P61_posjmp
  1704.     moveq    #0,d0
  1705.     move.b    P61_Info(a5),d0
  1706.     cmp    P61_slen-P61_cn(a3),d0
  1707.     blo.b    .e
  1708.     moveq    #0,d0
  1709. .e    move    d0,P61_Pos-P61_cn(a3)
  1710.     add.l    P61_possibase(pc),d0
  1711.     move.l    d0,P61_spos-P61_cn(a3)
  1712.     endc
  1713.  
  1714.     ifne    P61_pb
  1715. P61_pattbreak
  1716.     moveq    #64,d0
  1717.     move    d0,P61_rowpos-P61_cn(a3)
  1718.     clr    P61_CRow-P61_cn(a3)
  1719.     move.l    P61_spos(pc),a1
  1720.     move.l    P61_patternbase(pc),a0
  1721.     addq    #1,P61_Pos-P61_cn(a3)
  1722.     move.b    (a1)+,d0
  1723.     bpl.b    P61_dk2
  1724.     move.l    P61_possibase(pc),a1
  1725.     move.b    (a1)+,d0
  1726.     clr    P61_Pos-P61_cn(a3)
  1727. P61_dk2    move.l    a1,P61_spos-P61_cn(a3)
  1728.     move.l    P61_positionbase(pc),a1
  1729.     move    d0,P61_Patt-P61_cn(a3)
  1730.     lsl    #3,d0
  1731.     add.l    d0,a1
  1732.     movem    (a1),d0-d3
  1733.     lea    (a0,d0.l),a1
  1734.     move    d1,d0
  1735.     move.l    a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  1736.     lea    (a0,d0.l),a1
  1737.     move.l    a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  1738.     move    d2,d0
  1739.     lea    (a0,d0.l),a1
  1740.     move.l    a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  1741.     move    d3,d0
  1742.     add.l    d0,a0
  1743.     move.l    a0,P61_ChaPos+P61_temp3-P61_cn(a3)
  1744.     bra    P61_fxdone
  1745.     endc
  1746.  
  1747.     ifne    P61_vib
  1748. P61_vibrato
  1749.     move.b    P61_Info(a5),d0
  1750.     beq    P61_fxdone
  1751.     move.b    d0,d1
  1752.     move.b    P61_VibCmd(a5),d2
  1753.     and.b    #$f,d0
  1754.     beq.b    P61_vibskip
  1755.     and.b    #$f0,d2
  1756.     or.b    d0,d2
  1757. P61_vibskip
  1758.     and.b    #$f0,d1
  1759.     beq.b    P61_vibskip2
  1760.     and.b    #$f,d2
  1761.     or.b    d1,d2
  1762. P61_vibskip2
  1763.     move.b    d2,P61_VibCmd(a5)
  1764.     bra    P61_fxdone
  1765.     endc
  1766.  
  1767.     ifne    P61_tre
  1768. P61_settremo
  1769.     move.b    P61_Info(a5),d0
  1770.     beq    P61_fxdone
  1771.     move.b    d0,d1
  1772.     move.b    P61_TreCmd(a5),d2
  1773.     moveq    #$f,d3
  1774.     and.b    d3,d0
  1775.     beq.b    P61_treskip
  1776.     and.b    #$f0,d2
  1777.     or.b    d0,d2
  1778. P61_treskip
  1779.     and.b    #$f0,d1
  1780.     beq.b    P61_treskip2
  1781.     and.b    d3,d2
  1782.     or.b    d1,d2
  1783. P61_treskip2
  1784.     move.b    d2,P61_TreCmd(a5)
  1785.     bra    P61_fxdone
  1786.     endc
  1787.  
  1788.     ifne    P61_ec
  1789. P61_ecommands
  1790.     move.b    P61_Info(a5),d0
  1791.     and.b    #$f0,d0
  1792.     lsr    #3,d0
  1793.     move    P61_etab(pc,d0),d0
  1794.     jmp    P61_etab(pc,d0)
  1795.  
  1796. P61_etab
  1797.     ifne    P61_fi
  1798.     dc    P61_filter-P61_etab
  1799.     else
  1800.     dc    P61_fxdone-P61_etab
  1801.     endc
  1802.  
  1803.     ifne    P61_fsu
  1804.     dc    P61_fineup-P61_etab
  1805.     else
  1806.     dc    P61_fxdone-P61_etab
  1807.     endc
  1808.  
  1809.     ifne    P61_fsd
  1810.     dc    P61_finedwn-P61_etab
  1811.     else
  1812.     dc    P61_fxdone-P61_etab
  1813.     endc
  1814.  
  1815.     dc    P61_fxdone-P61_etab
  1816.     dc    P61_fxdone-P61_etab
  1817.  
  1818.     ifne    P61_sft
  1819.     dc    P61_setfinetune-P61_etab
  1820.     else
  1821.     dc    P61_fxdone-P61_etab
  1822.     endc
  1823.  
  1824.     ifne    P61_pl
  1825.     dc    P61_patternloop-P61_etab
  1826.     else
  1827.     dc    P61_fxdone-P61_etab
  1828.     endc
  1829.  
  1830.     dc    P61_fxdone-P61_etab
  1831.  
  1832.     ifne    P61_timing
  1833.     dc    P61_sete8-P61_etab
  1834.     else
  1835.     dc    P61_fxdone-P61_etab
  1836.     endc
  1837.  
  1838.     ifne    P61_rt
  1839.     dc    P61_setretrig-P61_etab
  1840.     else
  1841.     dc    P61_fxdone-P61_etab
  1842.     endc
  1843.  
  1844.     ifne    P61_fvu
  1845.     dc    P61_finevup-P61_etab
  1846.     else
  1847.     dc    P61_fxdone-P61_etab
  1848.     endc
  1849.  
  1850.     ifne    P61_fvd
  1851.     dc    P61_finevdwn-P61_etab
  1852.     else
  1853.     dc    P61_fxdone-P61_etab
  1854.     endc
  1855.  
  1856.     dc    P61_fxdone-P61_etab
  1857.  
  1858.     ifne    P61_nd
  1859.     dc    P61_ndelay-P61_etab
  1860.     else
  1861.     dc    P61_fxdone-P61_etab
  1862.     endc
  1863.  
  1864.     ifne    P61_pde
  1865.     dc    P61_pattdelay-P61_etab
  1866.     else
  1867.     dc    P61_fxdone-P61_etab
  1868.     endc
  1869.  
  1870.     ifne    P61_il
  1871.     dc    P61_funk-P61_etab
  1872.     else
  1873.     dc    P61_fxdone-P61_etab
  1874.     endc
  1875.     endc
  1876.  
  1877.     ifne    P61_fi
  1878. P61_filter
  1879.     move.b    P61_Info(a5),d0
  1880.     and.b    #$fd,$bfe001
  1881.     or.b    d0,$bfe001
  1882.     bra    P61_fxdone
  1883.     endc
  1884.  
  1885.     ifne    P61_fsu
  1886. P61_fineup
  1887.     P61_getnote
  1888.  
  1889.     moveq    #$f,d0
  1890.     and.b    P61_Info(a5),d0
  1891.     sub    d0,P61_Period(a5)
  1892.     moveq    #113,d0
  1893.     cmp    P61_Period(a5),d0
  1894.     ble.b    .jup
  1895.     move    d0,P61_Period(a5)
  1896. .jup    moveq    #$7e,d0
  1897.     and.b    (a5),d0
  1898.     bne    P61_zample
  1899.     bra    P61_nocha
  1900.     endc
  1901.  
  1902.     ifne    P61_fsd
  1903. P61_finedwn
  1904.     P61_getnote
  1905.  
  1906.     moveq    #$f,d0
  1907.     and.b    P61_Info(a5),d0
  1908.     add    d0,P61_Period(a5)
  1909.     cmp    #856,P61_Period(a5)
  1910.     ble.b    .jup
  1911.     move    #856,P61_Period(a5)
  1912. .jup    moveq    #$7e,d0
  1913.     and.b    (a5),d0
  1914.     bne    P61_zample
  1915.     bra    P61_nocha
  1916.     endc
  1917.  
  1918.     ifne    P61_sft
  1919. P61_setfinetune
  1920.     moveq    #$f,d0
  1921.     and.b    P61_Info(a5),d0
  1922.     ifeq    opt020
  1923.     add    d0,d0
  1924.     move    P61_mulutab(pc,d0),P61_Fine(a5)
  1925.     else
  1926.     move    P61_mulutab(pc,d0*2),P61_Fine(a5)
  1927.     endc
  1928.     bra    P61_fxdone
  1929.  
  1930. P61_mulutab
  1931.     dc    0,74,148,222,296,370,444,518,592,666,740,814,888,962,1036,1110
  1932.     endc
  1933.  
  1934.     ifne    P61_pl
  1935. P61_patternloop
  1936.     moveq    #$f,d0
  1937.     and.b    P61_Info(a5),d0
  1938.     beq.b    P61_setloop
  1939.  
  1940.     tst.b    P61_plflag-P61_cn(a3)
  1941.     bne.b    P61_noset
  1942.  
  1943.     move    d0,P61_plcount-P61_cn(a3)
  1944.     st.b    P61_plflag-P61_cn(a3)
  1945. P61_noset
  1946.     tst    P61_plcount-P61_cn(a3)
  1947.     bne.b    P61_looppaa
  1948.     clr.b    P61_plflag-P61_cn(a3)
  1949.     bra    P61_fxdone
  1950.     
  1951. P61_looppaa
  1952.     st.b    P61_plflag+1-P61_cn(a3)
  1953.     subq    #1,P61_plcount-P61_cn(a3)
  1954.     bra    P61_fxdone
  1955.  
  1956. P61_setloop
  1957.     tst.b    P61_plflag-P61_cn(a3)
  1958.     bne    P61_fxdone
  1959.     move    P61_rowpos(pc),P61_plrowpos-P61_cn(a3)
  1960.     lea    P61_temp0+P61_TData(pc),a1
  1961.     lea    P61_looppos(pc),a0
  1962.     moveq    #channels-1,d0
  1963. .talt    move.l    (a1)+,(a0)+
  1964.     move.l    (a1)+,(a0)+
  1965.     move.l    (a1),(a0)+
  1966.     subq.l    #8,a1
  1967.     add.l    d6,a1
  1968.     dbf    d0,.talt
  1969.     bra    P61_fxdone
  1970.     endc
  1971.  
  1972.     ifne    P61_fvu
  1973. P61_finevup
  1974.     moveq    #$f,d0
  1975.     and.b    P61_Info(a5),d0
  1976.     add    d0,P61_Volume(a5)
  1977.     moveq    #64,d0
  1978.     cmp    P61_Volume(a5),d0
  1979.     bge    P61_fxdone
  1980.     move    d0,P61_Volume(a5)
  1981.     bra    P61_fxdone
  1982.     endc
  1983.  
  1984.     ifne    P61_fvd
  1985. P61_finevdwn
  1986.     moveq    #$f,d0
  1987.     and.b    P61_Info(a5),d0
  1988.     sub    d0,P61_Volume(a5)
  1989.     bpl    P61_fxdone
  1990.     clr    P61_Volume(a5)
  1991.     bra    P61_fxdone
  1992.     endc
  1993.  
  1994.     ifne    P61_timing
  1995. P61_sete8
  1996.     moveq    #$f,d0
  1997.     and.b    P61_Info(a5),d0
  1998.     move    d0,P61_E8-P61_cn(a3)
  1999.     bra    P61_fxdone
  2000.     endc
  2001.  
  2002.     ifne    P61_rt
  2003. P61_setretrig
  2004.     moveq    #$f,d0
  2005.     and.b    P61_Info(a5),d0
  2006.     move    d0,P61_RetrigCount(a5)
  2007.     bra    P61_fxdone
  2008.     endc
  2009.  
  2010.     ifne    P61_nd
  2011. P61_ndelay
  2012.     moveq    #$7e,d0
  2013.     and.b    (a5),d0
  2014.     beq    P61_skip
  2015.     ifne    P61_vib
  2016.     clr.b    P61_VibPos(a5)
  2017.     endc
  2018.     ifne    P61_tre
  2019.     clr.b    P61_TrePos(a5)
  2020.     endc
  2021.     ifne    P61_ft
  2022.     add    P61_Fine(a5),d0
  2023.     endc
  2024.     move    d0,P61_Note(a5)
  2025.     move    (a2,d0),P61_Period(a5)
  2026.     ifeq    fade
  2027.     move    P61_Volume(a5),8(a4)
  2028.     else
  2029.     move    P61_Volume(a5),P61_Shadow(a5)
  2030.     endc
  2031.     bra    P61_skip
  2032.     endc
  2033.  
  2034.     ifne    P61_pde
  2035. P61_pattdelay
  2036.     moveq    #$f,d0
  2037.     and.b    P61_Info(a5),d0
  2038.     move    d0,P61_pdelay-P61_cn(a3)
  2039.     st    P61_pdflag-P61_cn(a3)
  2040.     bra    P61_fxdone
  2041.     endc
  2042.  
  2043.     ifne    P61_sd
  2044. P61_cspeed
  2045.     moveq    #0,d0
  2046.     move.b    P61_Info(a5),d0
  2047.  
  2048.     ifne    CIA
  2049.     tst    P61_Tempo-P61_cn(a3)
  2050.     beq.b    P61_VBlank
  2051.     cmp.b    #32,d0
  2052.     bhs.b    P61_STempo
  2053.     endc
  2054.  
  2055. P61_VBlank
  2056.     cmp.b    #1,d0
  2057.     beq.b    P61_jkd
  2058.  
  2059.     move.b    d0,P61_speed+1-P61_cn(a3)
  2060.     subq.b    #1,d0
  2061.     move.b    d0,P61_speed2+1-P61_cn(a3)
  2062.     clr    P61_speedis1-P61_cn(a3)
  2063.     bra    P61_fxdone
  2064.  
  2065. P61_jkd    move.b    d0,P61_speed+1-P61_cn(a3)
  2066.     move.b    d0,P61_speed2+1-P61_cn(a3)
  2067.     st    P61_speedis1-P61_cn(a3)
  2068.     bra    P61_fxdone
  2069.  
  2070.  
  2071.     ifne    CIA
  2072. P61_STempo
  2073.     move.l    P61_timer(pc),d1
  2074.     divu    d0,d1
  2075.     move    d1,P61_thi2-P61_cn(a3)
  2076.     sub    #$1f0*2,d1
  2077.     move    d1,P61_thi-P61_cn(a3)
  2078.  
  2079.     ifeq    system
  2080.     move    P61_thi2-P61_cn(a3),d1
  2081.     move.b    d1,$bfd400
  2082.     lsr    #8,d1
  2083.     move.b    d1,$bfd500
  2084.     endc
  2085.  
  2086.     bra    P61_fxdone
  2087.     endc
  2088.     endc
  2089.  
  2090.  
  2091.  
  2092.     ifne    P61_vbvs
  2093. P61_vibochvslide
  2094.     move.b    P61_Info(a5),d0
  2095.     sub.b    d0,P61_Volume+1(a5)
  2096.     bpl.b    P61_test62
  2097.     clr    P61_Volume(a5)
  2098.     ifeq    fade
  2099.     clr    8(a4)
  2100.     else
  2101.     clr    P61_Shadow(a5)
  2102.     endc
  2103.     bra.b    P61_vib2
  2104. P61_test62
  2105.     moveq    #64,d0
  2106.     cmp    P61_Volume(a5),d0
  2107.     bge.b    .ncs2
  2108.     move    d0,P61_Volume(a5)
  2109. .ncs2
  2110.     ifeq    fade
  2111.     move    P61_Volume(a5),8(a4)
  2112.     else
  2113.     move    P61_Volume(a5),P61_Shadow(a5)
  2114.     endc
  2115.     endc
  2116.  
  2117.     ifne    P61_vib
  2118. P61_vib2
  2119.     move    #$f00,d0
  2120.     move    P61_VibCmd(a5),d1
  2121.     and    d1,d0
  2122.     lsr    #3,d0
  2123.  
  2124.     lsr    #2,d1
  2125.     and    #$1f,d1
  2126.     add    d1,d0
  2127.  
  2128.     move    P61_Period(a5),d1
  2129.     moveq    #0,d2
  2130.     move.b    P61_vibtab(pc,d0),d2
  2131.  
  2132.     tst.b    P61_VibPos(a5)
  2133.     bmi.b    .vibneg
  2134.     add    d2,d1
  2135.     bra.b    P61_vib4
  2136.  
  2137. .vibneg    sub    d2,d1
  2138.  
  2139. P61_vib4
  2140.     move    d1,6(a4)
  2141.     move.b    P61_VibCmd(a5),d0
  2142.     lsr.b    #2,d0
  2143.     and    #$3c,d0
  2144.     add.b    d0,P61_VibPos(a5)
  2145.     bra    P61_contfxdone
  2146.     endc
  2147.  
  2148.     ifne    P61_tre
  2149. P61_tremo
  2150.     move    #$f00,d0
  2151.     move    P61_TreCmd(a5),d1
  2152.     and    d1,d0
  2153.     lsr    #3,d0
  2154.     
  2155.     lsr    #2,d1
  2156.     and    #$1f,d1
  2157.     add    d1,d0
  2158.  
  2159.     move    P61_Volume(a5),d1
  2160.     moveq    #0,d2
  2161.     move.b    P61_vibtab(pc,d0),d2
  2162.  
  2163.     tst.b    P61_TrePos(a5)
  2164.     bmi.b    .treneg
  2165.     add    d2,d1
  2166.     cmp    #64,d1
  2167.     ble.b    P61_tre4
  2168.     moveq    #64,d1
  2169.     bra.b    P61_tre4
  2170.  
  2171. .treneg    sub    d2,d1
  2172.     bpl.b    P61_tre4
  2173.     moveq    #0,d1
  2174. P61_tre4
  2175.     ifeq    fade
  2176.     move    d1,8(a4)
  2177.     else
  2178.     move    d1,P61_Shadow(a5)
  2179.     endc
  2180.  
  2181.     move.b    P61_TreCmd(a5),d0
  2182.     lsr.b    #2,d0
  2183.     and    #$3c,d0
  2184.     add.b    d0,P61_TrePos(a5)
  2185.     bra    P61_contfxdone
  2186.     endc
  2187.  
  2188.     ifne    P61_vib!P61_tre
  2189. P61_vibtab
  2190.     incbin    "data/p61a.vibtab"
  2191.     endc
  2192.  
  2193.     ifne    P61_il
  2194. P61_funk
  2195.     moveq    #$f,d0
  2196.     and.b    P61_Info(a5),d0
  2197.     move.b    d0,P61_Funkspd(a5)
  2198.     bra    P61_fxdone
  2199.  
  2200. P61_funk2
  2201.     moveq    #0,d0
  2202.     move.b    P61_Funkspd(a5),d0
  2203.     beq.b    P61_funkend
  2204.     move.b    P61_FunkTable(pc,d0),d0
  2205.     add.b    d0,P61_Funkoff(a5)
  2206.     bpl.b    P61_funkend
  2207.     clr.b    P61_Funkoff(a5)
  2208.  
  2209.     move.l    P61_Sample(a5),a1
  2210.     move.l    P61_RepeatOffset(a1),d1
  2211.     move    P61_RepeatLength(a1),d0
  2212.     add.l    d0,d0
  2213.     add.l    d1,d0
  2214.     move.l    P61_Wave(a5),a0
  2215.     addq.l    #1,a0
  2216.     cmp.l    d0,a0
  2217.     blo.b    P61_funkok
  2218.     move.l    d1,a0
  2219. P61_funkok
  2220.     move.l    a0,P61_Wave(a5)
  2221.     not.b    (a0)
  2222. P61_funkend
  2223.     rts
  2224.  
  2225. P61_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
  2226.     endc
  2227.  
  2228. P61_jtab
  2229.     dc    P61_fxdone-*
  2230.     dc    P61_fxdone-*
  2231.     dc    P61_fxdone-*
  2232.  
  2233.     ifne    P61_tp
  2234.     dc    P61_settoneport-*
  2235.     else
  2236.     dc    P61_fxdone-*
  2237.     endc
  2238.  
  2239.     ifne    P61_vib
  2240.     dc    P61_vibrato-*
  2241.     else
  2242.     dc    P61_fxdone-*
  2243.     endc
  2244.  
  2245.     ifne    P61_tpvs
  2246.     dc    P61_toponochange-*
  2247.     else
  2248.     dc    P61_fxdone-*
  2249.     endc
  2250.  
  2251.     dc    P61_fxdone-*
  2252.  
  2253.     ifne    P61_tre
  2254.     dc    P61_settremo-*
  2255.     else
  2256.     dc    P61_fxdone-*
  2257.     endc
  2258.  
  2259.     dc    P61_fxdone-*
  2260.  
  2261.     ifne    P61_sof
  2262.     dc    P61_sampleoffse-*
  2263.     else
  2264.     dc    P61_fxdone-*
  2265.     endc
  2266.     dc    P61_fxdone-*
  2267.  
  2268.     ifne    P61_pj
  2269.     dc    P61_posjmp-*
  2270.     else
  2271.     dc    P61_fxdone-*
  2272.     endc
  2273.  
  2274.     ifne    P61_vl
  2275.     dc    P61_volum-*
  2276.     else
  2277.     dc    P61_fxdone-*
  2278.     endc
  2279.  
  2280.     ifne    P61_pb
  2281.     dc    P61_pattbreak-*
  2282.     else
  2283.     dc    P61_fxdone-*
  2284.     endc
  2285.  
  2286.     ifne    P61_ec
  2287.     dc    P61_ecommands-*
  2288.     else
  2289.     dc    P61_fxdone-*
  2290.     endc
  2291.     
  2292.     ifne    P61_sd
  2293.     dc    P61_cspeed-*
  2294.     else
  2295.     dc    P61_fxdone-*
  2296.     endc
  2297.  
  2298.  
  2299. P61_dmason
  2300.     ifeq    system
  2301.     tst.b    $bfdd00
  2302.     move    #$2000,$dff09c
  2303.     move.b    #$19,$bfdf00
  2304.     move.l    a0,-(sp)
  2305.     move.l    P61_vektori(pc),a0
  2306.     move.l    P61_intaddr(pc),(a0)
  2307.     move.l    (sp)+,a0
  2308.     move    P61_dma(pc),$dff096
  2309.     nop
  2310.     rte
  2311.  
  2312.     else
  2313.  
  2314.     move    P61_dma(pc),$96(a6)
  2315.     lea    P61_server(pc),a3
  2316.     addq    #1,(a3)
  2317.     move.l    P61_craddr(pc),a0
  2318.     move.b    #$19,(a0)
  2319.     bra    P61_ohi
  2320.     endc
  2321.  
  2322.  
  2323. P61_setrepeat
  2324.     ifeq    system
  2325.     tst.b    $bfdd00
  2326.     movem.l    a0/a1,-(sp)
  2327.     lea    $dff0a0,a1
  2328.     move    #$2000,-4(a1)
  2329.     else
  2330.     lea    $a0(a6),a1
  2331.     endc
  2332.  
  2333.     move.l    P61_Sample+P61_temp0(pc),a0
  2334.     addq.l    #6,a0
  2335.     move.l    (a0)+,(a1)+
  2336.     move    (a0),(a1)
  2337.  
  2338.     ifgt    channels-1
  2339.     move.l    P61_Sample+P61_temp1(pc),a0
  2340.     addq.l    #6,a0
  2341.     move.l    (a0)+,12(a1)
  2342.     move    (a0),16(a1)
  2343.     endc
  2344.     
  2345.     ifgt    channels-2
  2346.     move.l    P61_Sample+P61_temp2(pc),a0
  2347.     addq.l    #6,a0
  2348.     move.l    (a0)+,28(a1)
  2349.     move    (a0),32(a1)
  2350.     endc
  2351.  
  2352.     ifgt    channels-3
  2353.     move.l    P61_Sample+P61_temp3(pc),a0
  2354.     addq.l    #6,a0
  2355.     move.l    (a0)+,44(a1)
  2356.     move    (a0),48(a1)
  2357.     endc
  2358.  
  2359.     ifne    system
  2360.     ifne    CIA
  2361.     lea    P61_server(pc),a3
  2362.     clr    (a3)
  2363.     move.l    P61_craddr+4(pc),a0
  2364.     move.b    P61_tlo(pc),(a0)
  2365.     move.b    P61_thi(pc),$100(a0)
  2366.     endc
  2367.     bra    P61_ohi
  2368.     endc
  2369.  
  2370.     ifeq    system
  2371.     ifne    CIA
  2372.     move.l    P61_vektori(pc),a0
  2373.     move.l    P61_tintti(pc),(a0)
  2374.     endc
  2375.     movem.l    (sp)+,a0/a1
  2376.     nop
  2377.     rte
  2378.     endc
  2379.  
  2380. P61_temp0    dcb.b    Channel_Block_SIZE-2
  2381.         dc    1
  2382.  
  2383. P61_temp1    dcb.b    Channel_Block_SIZE-2
  2384.         dc    2
  2385.  
  2386. P61_temp2    dcb.b    Channel_Block_SIZE-2
  2387.         dc    4
  2388.  
  2389. P61_temp3    dcb.b    Channel_Block_SIZE-2
  2390.         dc    8
  2391.  
  2392. P61_cn        dc    0
  2393. P61_dma        dc    $8200
  2394. P61_rowpos    dc    0
  2395. P61_slen    dc    0
  2396. P61_speed    dc    0
  2397. P61_speed2    dc    0
  2398. P61_speedis1    dc    0
  2399. P61_spos    dc.l    0
  2400.  
  2401.     ifeq    system
  2402. P61_vektori    dc.l    0
  2403. P61_oldlev6    dc.l    0
  2404.     endc
  2405.  
  2406. P61_ofilter    dc    0
  2407. P61_timers    dc.l    0
  2408.  
  2409.     ifne    CIA
  2410. P61_tintti    dc.l    0
  2411. P61_thi        dc.b    0
  2412. P61_tlo        dc.b    0
  2413. P61_thi2    dc.b    0
  2414. P61_tlo2    dc.b    0
  2415. P61_timer    dc.l    0
  2416.     endc
  2417.  
  2418.     ifne    P61_pl
  2419. P61_plcount    dc    0
  2420. P61_plflag    dc    0
  2421. P61_plreset    dc    0
  2422. P61_plrowpos    dc    0
  2423. P61_looppos    dcb.b    12*channels
  2424.     endc
  2425.  
  2426.     ifne    P61_pde
  2427. P61_pdelay    dc    0
  2428. P61_pdflag    dc    0
  2429.     endc
  2430.  
  2431. P61_samples    dcb.b    16*31
  2432. P61_emptysample    dcb.b    16
  2433. P61_positionbase dc.l    0
  2434. P61_possibase    dc.l    0
  2435. P61_patternbase    dc.l    0
  2436. P61_intaddr    dc.l    0
  2437.  
  2438.     ifne    system
  2439. P61_server    dc    0
  2440. P61_miscbase    dc.l    0
  2441. P61_audioopen    dc.b    0
  2442. P61_sigbit    dc.b    -1
  2443. P61_ciares    dc.l    0
  2444. P61_craddr    dc.l    0,0,0
  2445. P61_dat        dc    $f00
  2446. P61_timerinterrupt dc    0,0,0,0,127
  2447. P61_timerdata    dc.l    0,0,0
  2448. P61_timeron    dc    0
  2449. P61_allocport    dc.l    0,0
  2450.         dc.b    4,0
  2451.         dc.l    0
  2452.         dc.b    0,0
  2453.         dc.l    0
  2454. P61_reqlist    dc.l    0,0,0
  2455.         dc.b    5,0
  2456. P61_allocreq    dc.l    0,0
  2457.         dc    127
  2458.         dc.l    0
  2459. P61_portti    dc.l    0
  2460.         dc    68
  2461.         dc.l    0,0,0
  2462.         dc    0
  2463. P61_reqdata    dc.l    0
  2464.         dc.l    1,0,0,0,0,0,0
  2465.         dc    0
  2466. P61_audiodev    dc.b    'audio.device',0
  2467.  
  2468. P61_cianame    dc.b    'ciab.resource',0
  2469. P61_timeropen    dc.b    0
  2470. P61_timerint    dc.b    'P61_TimerInterrupt',0,0
  2471.     endc
  2472. P61_etu
  2473.         even
  2474.  
  2475. ******** END OF BINARY FILE **************
  2476.  
  2477. ;    section    chip,data_c
  2478. ;P61_data    incbin    "P61:P61.stay cool..."
  2479. ;P61_smp    incbin    "ram:SMP.fields of green"
  2480.  
  2481. ;    section    smp,bss_c
  2482. ;samples    ;ds.b    $10000        ;uncomment if you have packed samples
  2483.                 ;and insert sample buffer length
  2484.